package top.timous.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.timous.pojo.UserInfo;
import top.timous.service.EpidemicService;
import top.timous.vo.EpidemicInfoVo;

import javax.servlet.http.HttpSession;
import java.util.Map;


@Controller
@RequestMapping("/epidemicData")
public class EpidemicController {


    @Autowired
    private EpidemicService epidemicService;
    /**
     * 省份疫情信息的录入
     * EpidemicInfoVo接收页面传递过来的数据
     * @return
     */
    @RequestMapping("/ajax/input")
    @ResponseBody
    public Map<String, Object> input(@RequestBody  EpidemicInfoVo epidemicInfoVo , HttpSession session){ // Map<String , Object> maps 这里可以使用map进行数据的接收
        /**
         * 可以使用拦截器做权限的问题
         */
        UserInfo loginedUser = (UserInfo) session.getAttribute("loginedUser");
        return epidemicService.input(loginedUser.getUserId(),epidemicInfoVo);
    }


    @RequestMapping("/ajax/lastestData")
    @ResponseBody
    public Map<String , Object> EpidemicDetail(){
        return epidemicService.EpidemicDetail();
    }
    @RequestMapping("/ajax/lastestDatas")
    @ResponseBody
    public Map<String , Object> EpidemicDetails(){
        return epidemicService.EpidemicDetails();
    }

}
